<?php

class M_todolist extends CI_Model
{

    
    
    
    public function lay_danh_sach_task()
        {
            $result= $this->db->get('todo_list');
            if($result->num_rows()>0)
                return $result->result();
            else
                return false;
        }
         public function lay_danh_sach_task_moi_chua_nhan()
        {
            $this->db->where(array('STATUS'=>1,'ACCOUNT_ID'=>null));
            $result= $this->db->get('todo_list');
            if($result->num_rows()>0)
                return $result->result();
            else
                return false;
        }
        public function lay_danh_sach_task_moi_da_nhan()
        {
            $this->db->where('STATUS',1);
            $this->db->where('ACCOUNT_ID != ""');
            $result= $this->db->get('todo_list');
            if($result->num_rows()>0)
                return $result->result();
            else
                return false;
        }
        public function lay_danh_sach_task_moi_da_nhan_theo_account($id)
        {
            $this->db->where('STATUS',1);
            $this->db->where('ACCOUNT_ID',$id);
            $result= $this->db->get('todo_list');
            if($result->num_rows()>0)
                return $result->result();
            else
                return false;
        }
     public function lay_task_id($id)
        {
            $this->db->where(array('TODO_LIST_ID'=>$id));
            $result= $this->db->get('todo_list');
            if($result->num_rows()>0)
                return $result->row();
            else
                return false;
        }
      public function them_task($ACCOUNT_ID,$TASK_TITLE,$TASK_DETAILS, $START_DATE, $DEADLINE, $Level, $STATUS)
        {
            $data['ACCOUNT_ID']=$ACCOUNT_ID;
            $data['TASK_TITLE']=$TASK_TITLE;
            $data['TASK_DETAILS']=$TASK_DETAILS;
            $data['START_DATE']=$START_DATE;
            $data['DEADLINE']=$DEADLINE;
            $data['Level']=$Level;
            $data['STATUS']=$STATUS;
          //  var_dump($data); exit;
            return $this->db->insert('todo_list',$data);
        }
        public function cap_nhat_task($TODO_LIST_ID,$ACCOUNT_ID,$TASK_TITLE,$TASK_DETAILS, $START_DATE, $DEADLINE, $Level, $STATUS)
        {
            $data['ACCOUNT_ID']=$ACCOUNT_ID;
            $data['TASK_TITLE']=$TASK_TITLE;
            $data['TASK_DETAILS']=$TASK_DETAILS;
            $data['START_DATE']=$START_DATE;
            $data['DEADLINE']=$DEADLINE;
            $data['Level']=$Level;
            $data['STATUS']=$STATUS;
            return $this->db->update('todo_list',$data,array('TODO_LIST_ID'=>$TODO_LIST_ID));
        }
         public function nhan_vien_accept($TODO_LIST_ID,$ACCOUNT_ID)
        {
            $data['ACCOUNT_ID']=$ACCOUNT_ID;
            return $this->db->update('todo_list',$data,array('TODO_LIST_ID'=>$TODO_LIST_ID));
        }
        public function xong_task($TODO_LIST_ID)
        {
            $data['STATUS']=0;
            return $this->db->update('todo_list',$data,array('TODO_LIST_ID'=>$TODO_LIST_ID));
        }
    
} ?>